package active.iterators;

import constructor.composite.Deparment;

import java.util.Iterator;
import java.util.List;

public class OutputPrint {

    private List<College> collegeList;

    public OutputPrint(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    public void collegeListForEach() {
        Iterator<College> collegeIterator = collegeList.iterator();
        while (collegeIterator.hasNext()) {
            College college = collegeIterator.next();
            System.out.println("=======" + college.getName() + "===========");
            printDeparment(college.createIterator());
        }
    }

    private void printDeparment(Iterator iterator) {
        while (iterator.hasNext()) {
            Deparment deparment = (Deparment) iterator.next();
            deparment.print();
        }
    }

}
